import request from '@/request';

// 根据当天经纬度逆解析获取当前所在城市
export function parseCity(data: any): Promise<any> {
  return request({
    url: 'https://apis.map.qq.com/ws/geocoder/v1/',
    method: 'get',
    data
  });
}

// 获取当前所在城市的未来多少小时的天气
export function getNextDayWeatherWithHours(city: string, hours = 24): Promise<any> {
  return request({
    url: `https://api.seniverse.com/v3/weather/hourly.json?key=${
      import.meta.env.VITE_API_KEY
    }&location=${city}&language=zh-Hans&unit=c&start=0&hours=${hours}`,
    method: 'get'
  });
}

// 获取当前所在城市的当前以及未来几天的天气
export function getWeatherWithDays(city: string, days = 7): Promise<any> {
  return request({
    url: `https://api.seniverse.com/v3/weather/daily.json?key=${
      import.meta.env.VITE_API_KEY
    }&location=${city}&language=zh-Hans&unit=c&start=0&days=${days}`,
    method: 'get'
  });
}
